package com.guoxin.chapter2.t8;

import java.util.stream.IntStream;

public class Task {
	
	public synchronized void otherMethod() {
		System.out.println("----------run--otherMethod");
	}

	/**
	 * 验证同步synchronized(this)代码块是锁定当前对象
	 */
	public void doLongTimeTask() {
		synchronized (this) {
			IntStream.range(0, 10000).forEach(
					i -> System.out.println("synchronized threadName=" + Thread.currentThread().getName() + (i + 1)));
		}
	}
}
